package com.hedl.practice.diyJava.multithreading.Interrupt_thread.practice.example1.entity;

import java.util.concurrent.TimeUnit;

/**
 * @author Big Watermelon
 * @description
 * @date 2024/02/20/09:14
 */
public class HelloThread extends Thread{
    @Override
    public void run(){
        int n = 0;

        //判断线程是否中断
        while (!isInterrupted()){
            n ++;
            System.out.println("HelloThread: "+n+"Hello.");

            try {
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}
